package com.frejoys.api.interfaces;

import com.frejoys.common.config.ValueConfig;
import com.frejoys.common.constant.UrlConstant;
import com.frejoys.common.vo.common.PushVo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.annotation.PostExchange;
import reactor.core.publisher.Mono;

/**
 * 收费气象接口
 */
public interface ApiCommonInterface {

    // 获取收费接口气象信息
    @GetExchange(url = UrlConstant.weatherUrl + "/gps-to-weather", accept = "application/json")
    Mono<String> getWeatherChargeApiInfo(@RequestParam("from") Integer from, @RequestParam("lng") Double lng, @RequestParam("lat") Double lat, @RequestParam("needMoreDay") Integer needMoreDay, @RequestHeader("Authorization") String auth);

    // 获取微信小程序码接口
    @PostExchange(url = UrlConstant.wxQrCodeUrl + "?access_token={accessToken}", accept = "application/json")
    Mono<byte[]> getWxQrCodeUrlApiInfo(@PathVariable("accessToken") String accessToken, @RequestBody Object scene);

    // H5获取AccessToken
    @GetExchange(url = UrlConstant.accessTokenUrl + "?appid={appid}&secret={secret}&code={code}&grant_type=authorization_code", accept = "application/json")
    Mono<String> getWxAccessTokenApiInfo(@PathVariable("appid") String appid,@PathVariable("secret") String secret,@PathVariable("code") String code);


    // H5验证AccessToken是否有效
    @GetExchange(url = UrlConstant.validateAccessTokenUrl + "?access_token={accessToken}&openid={openid}", accept = "application/json")
    Mono<String> validateAccessTokenApiInfo(@PathVariable("accessToken") String accessToken,@PathVariable("openid") String openid);

    // H5刷新AccessToken
    @GetExchange(url = UrlConstant.refreshTokenUrl + "?appid={appid}&grant_type=refresh_token&refresh_token={refreshToken}", accept = "application/json")
    Mono<String> wxRefreshTokenApiInfo(@PathVariable("appid") String appid,@PathVariable("refreshToken") String refreshToken);

    // H5获取用户信息
    @GetExchange(url = UrlConstant.userinfo + "?access_token={accessToken}&openid={openid}", accept = "application/json")
    Mono<String> getUserinfo(@PathVariable("accessToken") String accessToken,@PathVariable("openid") String openid);


    // 语音服务
    @PostExchange(url = UrlConstant.voiceUrl + "/voice/push", accept = "application/json")
    Mono<String> pushVoice(@RequestBody PushVo pushVo);


    // @PostExchange(url = "http://127.0.0.1:9000/voice/push", accept = "application/json")
    // Mono<String> pushVoice(@RequestBody PushVo pushVo);


}
